package net.wendal.nutzbook;

import java.util.Date;

import net.wendal.nutzbook.bean.User;

import org.nutz.dao.Dao;
import org.nutz.dao.util.Daos;
import org.nutz.ioc.Ioc;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;

import com.wsq.nutz.service.UserService;

public class MainSetup implements Setup{

	@Override
	public void init(NutConfig conf) {
		// 初始化数据库表
        Ioc ioc = conf.getIoc();
        Dao dao = ioc.get(Dao.class);
        // 如果没有createTablesInPackage,请检查nutz版本
        Daos.createTablesInPackage(dao, "net.wendal.nutzbook", false);
        
        
        // 初始化默认根用户
        if (dao.count(User.class) == 0) {
            UserService us = ioc.get(UserService.class);
            //us.add("admin", "123456");
        }
        
	}

	@Override
	public void destroy(NutConfig nc) {
		
	}
}
